<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Title</title>
  </head>
  <body>
  
  </body>
  
  <script>
    // 函数柯里化：将多参函数转换为单参函数
    const add = (a) => {
      return b => a + b
    }
    const addRes = add(3)(5);
    console.log(addRes) // 8
    
    // 记住上下文
    const remember = () => {
      // 使用let形成块级作用域闭包
      let a = 1
      return () => ++a;
    }
    const rememberRes = remember();
    console.log(rememberRes()) // 2
    console.log(rememberRes()) // 3
    
    // 模块化
    const modular = () => {
      let count = 0;
      return {
        increment: () => ++count,
        getCount: () => count
      }
    }
    const modularRes = modular();
    console.log(modularRes.increment()) // 1
    console.log(modularRes.getCount()) // 1
  </script>
</html>